Skip to main content link. Accesskey S
  • Help
  • HCL Logo
  • HCL Notes and Domino Application Development wiki
  • THIS WIKI IS READ-ONLY. Individual names altered for privacy purposes.
  • HCL Forums and Blogs
  • Home
  • Product Documentation
  • Community Articles
  • Learning Center
  • API Documentation
Search
Community Articles > Designing Applications > Designing XPage Applications > NotesDbDirectory sample JavaScript code for XPages
  • Share Show Menu▼
  • Subscribe Show Menu▼

Recent articles by this author

NotesName sample JavaScript code for XPages

Here is sample JavaScript code for the class NotesName. Eventually this sample code will find its way into the documentation. Corrections and comments are appreciated.

NotesMIMEEntity sample JavaScript code for XPages

Here is sample JavaScript code for the class NotesMIMEEntity. Eventually this sample code will find its way into the documentation. Corrections and comments are appreciated.

NotesViewEntryCollection sample JavaScript code for XPages

Here is sample JavaScript code for the class NotesViewEntryCollection. Eventually this sample code will find its way into the documentation. Corrections and comments are appreciated.

NotesViewNavigator sample JavaScript code for XPages

Here is sample JavaScript code for the class NotesViewNavigator. Eventually this sample code will find its way into the documentation. Corrections and comments are appreciated.

NotesViewEntry sample JavaScript code for XPages

Here is sample JavaScript code for the class NotesViewEntry. Eventually this sample code will find its way into the documentation. Corrections and comments are appreciated.
Community articleNotesDbDirectory sample JavaScript code for XPages
Added by ~Elizabeth Umkroskiettu | Edited by ~Elizabeth Umkroskiettu on December 22, 2010 | Version 2
  • Actions Show Menu▼
expanded Abstract
collapsed Abstract
Here is sample JavaScript code for the class NotesDatabase. Eventually this sample code will find its way into the documentation. Corrections and comments are appreciated.
ShowTable of Contents
HideTable of Contents
    • 0.1 IsHonorShowInOpenDatabaseDialog
    • 0.2 Name
    • 0.3 Parent
    • 0.4 createDatabase
    • 0.5 getClusterName
    • 0.6 getFirstDatabase
    • 0.7 getNextDatabase
    • 0.8 openDatabase
    • 0.9 openDatabaseByReplicaID
    • 0.10 openDatabaseIfModified
    • 0.11 openMailDatabase

IsHonorShowInOpenDatabaseDialog


This button toggles honoring Show in 'Open Application' dialog.

var dbdir:NotesDbDirectory = session.getDbDirectory("Sales/Acme");
var name:string = dbdir.getName();
if (dbdir.isHonorShowInOpenDatabaseDialog()) {
	dbdir.setHonorShowInOpenDatabaseDialog(false);
	requestScope.status = "Open database dialog not honored for " + name
} else {
	dbdir.setHonorShowInOpenDatabaseDialog(true);
	requestScope.status = "Open database dialog honored for " + name
}


Name


This computed field displays the name of a database directory set elsewhere on the page.

if (sessionScope.dbdir != null) {
	var dbdir:NotesDbDirectory = sessionScope.dbdir;
	return "Working on " + dbdir.getName();
} else {
	return "Working locally";
}


Parent


This computed field displays the parent user name when a database directory is instantiated elsewhere on the page.

if (sessionScope.dbdir != null) {
	var dbdir:NotesDbDirectory = sessionScope.dbdir;
	return dbdir.getParent().getUserName();
}


createDatabase


This button creates a new database in the local directory if it does not already exist.

var dbdir:NotesDbDirectory = session.getDbDirectory(null);
var dbname:string = "newdb";
var dbtitle:string = "New database";
try {
	dbdir.openDatabase(dbname);
	requestScope.status = "Already exists: " + dbname;
	return;
} catch(e) {} // proceed if there is an error i.e. the database does not already exist
var db:NotesDatabase = dbdir.createDatabase(dbname);
var view:NotesView = db.createView("main"); // need at least 1 view to initialize database
db.setTitle(dbtitle);
requestScope.status = "Created " + db.getFileName();


getClusterName


This computed field displays the cluster name for a database directory set elsewhere on the page.

if (sessionScope.dbdir != null) {
	var dbdir:NotesDbDirectory = sessionScope.dbdir;
	var cluster:string = dbdir.getClusterName("Sales/Acme"); // specifies a server
//	var cluster:string = dbdir.getClusterName(); // uses the current server
	if (cluster.isEmpty()) {
		cluster = "No cluster";
	}
	return "Cluster name: " + cluster;
}


getFirstDatabase


This data binding for a list box displays the names of all the databases in the current directory.

var out = "";
var dir = session.getDbDirectory("");
var db = dir.getFirstDatabase(NotesDbDirectory.DATABASE);
while (db != null) {
	out = out + db.getFileName() + "\n";
	db = dir.getNextDatabase();
}
return out


getNextDatabase


This data binding for a list box displays the names of all the databases in the current directory.

var out = "";
var dir = session.getDbDirectory("");
var db = dir.getFirstDatabase(NotesDbDirectory.DATABASE);
while (db != null) {
	out = out + db.getFileName() + "\n";
	db = dir.getNextDatabase();
}
return out


openDatabase


This button creates a new database in the local directory if it does not already exist.

var dbdir:NotesDbDirectory = session.getDbDirectory(null);
var dbname:string = "newdb";
var dbtitle:string = "New database";
try {
	dbdir.openDatabase(dbname);
	requestScope.status = "Already exists: " + dbname;
	return;
} catch(e) {} // proceed if there is an error i.e. the database does not already exist
var db:NotesDatabase = dbdir.createDatabase(dbname);
var view:NotesView = db.createView("main"); // need at least 1 view to initialize database
db.setTitle(dbtitle);
requestScope.status = "Created " + db.getFileName();


openDatabaseByReplicaID


This button opens a local database using a replica ID from elsewhere on the page.

var dir:NotesDbDirectory = session.getDbDirectory(null);
var rid:string = sessionScope.rid;
try {
	var db:NotesDatabase = dir.openDatabaseByReplicaID(rid);
} catch(e) {
	requestScope.status = "Cannot open database with replica ID " + rid;
	return;
}
requestScope.status = "Opened database " + db.getFileName();


openDatabaseIfModified


This button opens the local names.nsf if it was modified in the last 3 hours.

var dir:NotesDbDirectory = session.getDbDirectory(null);
var dt:NotesDateTime = session.createDateTime("Today");
dt.adjustHour(-3);
try {
	var db:NotesDatabase = dir.openDatabaseIfModified("names", dt);
} catch(e) {
	requestScope.status = "Database cannot be opened";
	return;
}
if (db != null) {
	requestScope.status = "Database opened";
} else {
	requestScope.status = "Database not modified in past 3 hours";
}


openMailDatabase


This button collects statistics on the current user's mail database.

try {

var db:NotesDatabase = session.getDbDirectory("NotesUA/Westford/Notes").openMailDatabase();
var dc:NotesDocumentCollection = db.getAllDocuments();
requestScope.status = "Mail database " + db.getTitle() + " is " +
(db.getSize()/1024).toFixed() + "KB long and has " + dc.getCount() + " documents";

} catch(e) {
	requestScope.status = "Error opening mail database\n" + e.toString();
}

  • Actions Show Menu▼


expanded Attachments (0)
collapsed Attachments (0)
Edit the article to add or modify attachments.
expanded Versions (2)
collapsed Versions (2)
Version Comparison     
VersionDateChanged by              Summary of changes
This version (2)Dec 22, 2010, 5:33:35 PM~Elizabeth Umkroskiettu  
1Dec 22, 2010, 5:26:54 PM~Ben Eljipypulettu  
expanded Comments (0)
collapsed Comments (0)
Copy and paste this wiki markup to link to this article from another article in this wiki.
Go ElsewhereStay ConnectedAbout
  • HCL Software
  • HCL Digital Solutions community
  • HCL Software support
  • BlogsDigital Solutions blog
  • Community LinkHCL Software forums and blogs
  • About HCL
  • Privacy
  • Accessibility